package qldc.pm.tiensu.searchcontainer.util.nguoicotiensu;

import qldc.pm.tiensu.dto.DoiTuongTienSuDTO;

import com.liferay.portal.kernel.util.OrderByComparator;

public class DoiTuongTienSuSoCMNDComparator extends OrderByComparator {
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	private final boolean _asc;

	public static String ORDER_BY_ASC = "soCMND ASC";
	public static String ORDER_BY_DESC = "soCMND DESC";

	public DoiTuongTienSuSoCMNDComparator() {
		this(false);
	}

	public DoiTuongTienSuSoCMNDComparator(boolean orderByAsc) {
		_asc = orderByAsc;
	}

	@Override
	public int compare(Object obj1, Object obj2) {
		DoiTuongTienSuDTO doiTuongTienSu1 = (DoiTuongTienSuDTO) obj1;
		DoiTuongTienSuDTO doiTuongTienSu2 = (DoiTuongTienSuDTO) obj2;

		int value = doiTuongTienSu1.getSoCMND().compareTo(doiTuongTienSu2.getSoCMND());

		if (this.equals(_asc)) {
			return value;
		} else {
			return -value;
		}
	}

	public String getOrderBy(){
		if (_asc) {
			return ORDER_BY_ASC;
		} else {
			return ORDER_BY_DESC;
		}
	}
}
